<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@page import="com.usernet.product.tools.AdminRight"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<link rel="stylesheet" type="text/css" href="resources/css/style.css">
		<script src="resources/js/comm.js"></script>
		<script src="resources/js/jquery-1.4.min.js"></script>
		<script type="text/javascript">
	function checkForm() {
		var name = $("#name").val();
		var develope = $("#develope").val();
		var share = document.getElementById("shareRadio");
		var money = $("#money").val();
		var tag = $("#tag").val();
		var tops = $("#tops").val();
		var typeId = $("#typeId").val();
		var recId = $("#recId").val();
		var recommend = $("#recommend").val();
		var remark = document.getElementById("remark").value;
		if(name == ""){
			alert("请输入软件名称 "); 
		}else if(develope == ""){
			alert("请输入开发商 ");   
		}else if(share.checked && money==""){
			alert("请输入金额\n类型为数字"); 
		}else if(typeId==0){
			alert("请选择所属分类");
		}else if(tops==-1){
			alert("是否推荐/顶置/推荐位置");
		}else if(recommend!="" && recommend<=0){
			alert("推荐位置需要大于0");
		}else if(remark == ""){
			alert("请输入软件介绍 ");   
		}else {
					loading();
					submitForm("addform");
		}
	}
	function changeRadio(bool){
		if(bool)
			$("#share_span").css("display","block");
		else
			$("#share_span").css("display","none");
	}
	function changeSel(flag){
		if(flag!=0 && flag!=-1){
			$("#tops_span").css("display","block");
			$("#recommend").val("${software.recommend}");}
		else{
			$("#tops_span").css("display","none");
			$("#recommend").val("");
			}
	}
</script>

	</head>

	<body onkeydown="if(event.keyCode==27) return false;">
		<jsp:include page="../inc/header.jsp"></jsp:include>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td height="30" background="resources/images/other/tab_05.gif">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="12" height="30">
								<img src="resources/images/other/tab_03.gif" width="12"
									height="30" />
							</td>
							<td>
								<div class="page_title">
									<img align="middle" src="resources/images/other/tb.gif"
										width="16" height="16" />
									软件信息管理 > 编辑软件
								</div>
							</td>
							<td>
								<div class="button_bar">
									<input value="返回" type="button" id="btn_back" class="common_button"
										onclick="javascript: history.go(-1);loading();">
									<input value="保存" type="button" id="btn_ok" class="common_button" onclick="checkForm();">
									<input value="刷新" type="button" id="btn_re" class="common_button"
										onclick="location='software.do?method=toUpdate&id=${software.id}';loading();">
								</div>
							</td>
							<td width="16" height="30">
								<img src="resources/images/other/tab_07.gif" width="16"
									height="30" />
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="8" background="resources/images/other/tab_12.gif">
							</td>
							<td>
								<form action="software.do" method="post" id="addform">
									<input type="hidden" name="method" value="doUpdate">
									<input type="hidden" name="id" value="${software.id }">
									<table cellspacing="1" cellpadding="0" class="query_form_table">
										<tr>
											<th>软件名称</th>
											<td><input value="${software.name }" name="name" id="name" class="comm_input" maxlength="50"/><span class="red_star">*</span></td>
										</tr>
										<tr>
											<th>开发商</th>
											<td><input value="${software.develope }" id="develope" name="develope" class="comm_input" maxlength="50"/></td>
										</tr>
										<tr style="display: none;">
											<th>是否收费</th>
											<td>
												<input onclick="changeRadio(false);" name="share" type="radio" <logic:equal value="0" name="software" property="share">checked</logic:equal> value="0"/>免费
												<input id="shareRadio" onclick="changeRadio(true);" name="share" type="radio" value="1" <logic:equal value="1" name="software" property="share">checked</logic:equal>/>收费
												<span id="share_span" style="<logic:equal value="0" name="software" property="share">display:none;</logic:equal><logic:equal value="1" name="software" property="share">display:block;</logic:equal>"><input value="<logic:equal value="1" name="software" property="share"><bean:write name="software" property="money" format="###"/></logic:equal>" id="money" name="money" class="comm_input" type="input" onpropertychange="if(!/^\d*(\.\d*)?$/.test(this.value))this.value=this.value.substr(0,this.value.length-1)" onpaste="return false"/>元<span class="red_star">*</span></span>
											</td>
										</tr>
										<tr>
											<th>所属分类</th>
											<td>
												<select id="typeId" name="typeId" class="comm_input">
													<option value="0">---请选择分类---</option>
													<logic:iterate id="type" name="types">
														<option value="${type.id }"<logic:present name="software" property="type"><logic:equal value="${type.id }" name="software" property="type.id">selected</logic:equal></logic:present>>${type.name }</option>
													</logic:iterate>
												</select>
												<span class="red_star">*</span>
											</td>
										</tr>
										<tr <logic:notEqual value="<%=String.valueOf(AdminRight.supers) %>" name="admin" property="flag">style="display:none;"</logic:notEqual>>
											<th>所属专题</th>
											<td>
												<select id="recId" name="recId" class="comm_input">
													<option value="0">---请选择专题---</option>
													<logic:iterate id="rec" name="resourcesList">
														<option value="${rec.id }"<logic:present name="software" property="resources"><logic:equal value="${rec.id }" name="software" property="resources.id">selected</logic:equal></logic:present>>${rec.name }</option>
													</logic:iterate>
												</select>
											</td>
										</tr>
										<tr <logic:notEqual value="<%=String.valueOf(AdminRight.supers) %>" name="admin" property="flag">style="display:none;"</logic:notEqual>>
											<th>是否推荐/顶置/推荐位置</th>
											<td>
												<select id="tops" name="tops" class="comm_input" onchange="changeSel(this.value);">
														<option value="-1">-请选择-</option>
														<option value="0"
														<logic:equal value="0" name="software" property="tops">
														selected
														</logic:equal>>不推荐,不顶置</option>
														<option value="1"
														<logic:equal value="1" name="software" property="tops">
														selected
														</logic:equal>>推荐</option>
														<option value="2"
														<logic:equal value="2" name="software" property="tops">
														selected
														</logic:equal>>顶置</option>
													</select><span class="red_star">*</span>
												<span id="tops_span" style="<logic:equal value="0" name="software" property="tops">display:none;</logic:equal><logic:equal value="2" name="software" property="tops">display:block;</logic:equal><logic:equal value="1" name="software" property="tops">display:block;</logic:equal>">
												<input value="${software.recommend }" id="recommend" name="recommend" class="comm_input" onpropertychange="if(!/^\d*(\.\d*)?$/.test(this.value))this.value=this.value.substr(0,this.value.length-1)" onpaste="return false"/>位
												<span class="red_star">*</span></span>
											</td>
										</tr>
										<tr <logic:notEqual value="<%=String.valueOf(AdminRight.supers) %>" name="admin" property="flag">style="display:none;"</logic:notEqual>>
											<th>评分信息</th>
											<td>
												<select name="avg" class="comm_input">
														<option value="0"
														<logic:equal value="0" name="software" property="avg">
														selected
														</logic:equal>>☆☆☆☆☆</option>
														<option value="1"
														<logic:equal value="1" name="software" property="avg">
														selected
														</logic:equal>>★☆☆☆☆</option>
														<option value="2"
														<logic:equal value="2" name="software" property="avg">
														selected
														</logic:equal>>★★☆☆☆</option>
														<option value="3"
														<logic:equal value="3" name="software" property="avg">
														selected
														</logic:equal>>★★★☆☆</option>
														<option value="4"
														<logic:equal value="4" name="software" property="avg">
														selected
														</logic:equal>>★★★★☆</option>
														<option value="5"
														<logic:equal value="5" name="software" property="avg">
														selected
														</logic:equal>>★★★★★</option>
													</select>
												<span class="red_star">*</span>
											</td>
										</tr>
										<tr style="display:none;">
											<th>支持版本</th>
											<td><input type="hidden" name="sdk" value="${software.sdk }"/></td>
										</tr>
										<tr>
											<th>标签</th>
											<td>
												<input value="${software.tag }" id="tag" name="tag" class="comm_input" maxlength="100"/>
												<span class="red_star">多个标签用"|"隔开</span>
											</td>
										</tr>
										<tr style="display: none;">
											<th>分享内容</th>
											<td>
												<textarea name="res" style="width:70%;height: 100px;"></textarea>
											</td>
										</tr>
										<tr>
											<th>软件描述</th>
											<td>
												<textarea id="remark" name="remark" style="width:70%;height: 200px;">${software.remark }</textarea>
												<span class="red_star">*</span>
											</td>
										</tr>
										<tr>
											<th colspan="2"><b>APK安装包信息</b></th>
										</tr>
										<tr>
											<th>版本</th>
											<td>${software.version }</td>
										</tr>
										<tr>
											<th>支持版本</th>
											<td>${software.sdk }</td>
										</tr>
										<tr>
											<th>版本号</th>
											<td>${software.code }</td>
										</tr>
										<tr>
											<th>包名</th>
											<td>${software.package_ }</td>
										</tr>
										<tr>
											<th>大小</th>
											<td>${software.size }</td>
										</tr>
										<tr>
											<th>图标</th>
											<td>
											<img src="upload/icon/${software.icon }"/>
										</tr>
									</table>
								</form>
							</td>
							<td width="8" background="resources/images/other/tab_15.gif">
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td height="35" background="resources/images/other/tab_19.gif">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="12" height="30">
								<img src="resources/images/other/tab_18.gif" width="12"
									height="35" />
							</td>
							<td>
								&nbsp;
							</td>
							<td width="16">
								<img src="resources/images/other/tab_20.gif" width="16"
									height="35" />
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</body>
</html>
<jsp:include page="../inc/footer.jsp"></jsp:include>